from PIL import Image

def Transform(filePath):
    im = Image.open(filePath)
    im = im.resize((400,100),Image.ANTIALIAS)
    gray = im.convert('L')
    threshold  =   140
    table  =  []
    for  i  in  range( 256 ):
        if  i  <  threshold:
            table.append(0)
        else :
            table.append(1)
    img = gray.point(table, "1")
    img.save('out.png', quality=100)

if __name__ == "__main__":
    Transform(filePath)
